package flc.ast.dialog;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.View;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ToastUtils;

import flc.ast.HomeActivity;
import flc.ast.R;
import flc.ast.activity.PrivacyFileActivity;
import flc.ast.databinding.DialogInputPasswordBinding;
import flc.ast.databinding.DialogSetPasswordBinding;
import flc.ast.utils.Content;
import flc.ast.view.PasscodeView;
import stark.common.basic.base.BaseSmartDialog;
import stark.common.basic.utils.SPUtil;

public class InputPasswordDialog extends BaseSmartDialog<DialogInputPasswordBinding> implements View.OnClickListener {

    public InputPasswordDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_input_password;
    }

    @Override
    protected void initView(View view) {
        String password = SPUtil.getString(getContext(), Content.myPassword, "");
        mDataBinding.passcodeView.setLocalPasscode(password);
        mDataBinding.passcodeView.setListener(new PasscodeView.PasscodeViewListener() {
            @Override
            public void onFail() {
                mDataBinding.passcodeView.getWrongStatusColor();
            }

            @Override
            public void onSuccess(String number) {
                dismiss();
                getContext().startActivity(new Intent(getContext(), PrivacyFileActivity.class));
            }
        });
        mDataBinding.passcodeView.setMyClickListener(new PasscodeView.MyClickListener() {
            @Override
            public void click() {
                if (listener != null) {
                    listener.click();
                }
            }
        });

    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
        }
    }

    private Ilistener listener;

    public void setListener(Ilistener listener) {
        this.listener = listener;
    }

    public interface Ilistener {
        void click();
    }
}
